<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Quick Start</title>
  <script src="/js/spritejs.js"></script>
  <style>
    html,body {
      margin: 0;
      padding: 0;
      background: #fff;
      height: 100%;
      width: 100%;
      max-width: 800px;
    }

    #stage {
      display: inline-block;
      width: 100%;
      height: 0;
      padding-bottom: 100%;
      background: #fff;
    }  
  </style>
</head>
<body>
  <div id="stage"></div>
  <script type="module">
  import {Vector2D} from './assets/js/vector2d.js';
  const container = document.getElementById('stage');
  const scene = new spritejs.Scene({
    container,
    width: 800,
    height: 800,
    // contextType: '2d',
  });

  const points = [new Vector2D(0, 100)];
  for(let i = 1; i <= 4; i++) {
    const p = points[0].copy().rotate(i * Math.PI * 0.4);
    points.push(p);
  }

  const layer = scene.layer();
  const polyline = new spritejs.Polyline({
    points: [
      points[0],
      points[2],
      points[4],
      points[1],
      points[3],
    ],
    fillColor: 'red',
    fillRule: 'evenodd',
    x: 300,
    y: 300,
  });
  layer.append(polyline);
  </script>
</body>
</html>